package DD;

import com.sun.org.apache.regexp.internal.RE;

import java.io.File;

import java.nio.file.Path;
import java.util.Scanner;

public class day10 {
    public static void main(String[] args) {
        System.out.println("请输入文件名的路径");
        String path = new Scanner(System.in).nextLine();
        File file = new File(path);
        long sum = Sizeof(file);
        System.out.println();

    }


    private static long Sizeof(File file) {
        File[] files = file.listFiles();
        long sum = 0;
        for (File a : files
        ) {
            if (a.isFile()) {
                sum = sum + a.length();
            } else if (a.isDirectory()) {
                sum = sum + Sizeof(a);
            }
        }
        return sum;
    }
}
